<template>
  <el-input v-model="sql" style="width: 240px" autosize type="textarea" placeholder="请输入SQL语句" clearable />
  <el-button type="primary" @click="search" style="margin-left: 20px;">立即分析</el-button>
  <el-card style="max-width: 480px;margin-top: 30px;">
    <p>{{ message }}</p>
    <a :href="message" target="_blank">立即查看结果</a>
  </el-card>

</template>

<script setup>
import { ref, onMounted, onUnmounted } from 'vue';
import axios from 'axios';
const message = ref();
const sql = ref('');
function search() {
  if (!sql.value) {
    message.value = '请输入SQL语句';
    return;
  }
  axios.post('http://127.0.0.1:8000/database/soar', { sql: sql.value })
    .then(response => {
      message.value = response.data.message;
    })
}

onMounted(() => {
  // Your code here
});

// 在组件卸载前执行的操作
onUnmounted(() => {
  // Your code here
});
</script>